<template>
	<BaseContainer>
		<el-tabs v-model="activeName" class="demo-tabs" @tab-click="onTabClick" tabPosition="left">
			<el-tab-pane v-for="(item, index) in tabs" :key="index" :label="item.label" :name="item.name">
				<component v-if="activeName == item.name" :is="item.component" :creditCode="item.creditCode"
				:isWithAuth="0" :ifShowSearch="false"></component>
			</el-tab-pane>
		</el-tabs>
	</BaseContainer>
</template>

<script setup lang="ts">
import safetyRegulatoryInfo from './components/videoSupervision/index.vue'
import intelligenceEquipment from './components/intelligenceEquipment/index.vue'
import maintenanceLog from './components/maintenanceLog/index.vue'
import fireInspecteLog from './components/fireInspecteLog/index.vue'
import monthlyFireInspecte from './components/monthlyFireInspecte/index.vue'
import fireMaintenance from './components/fireMaintenance/index.vue'
import fireDrill from './components/fireDrill/index.vue'
import safetyEduTrain from './components/safetyEduTrain/index.vue'
import facilityTest from './components/facilityTest/index.vue'
import appointOutList from './components/appointOutList/index.vue'
import earlyWarningAlarmLog from './components/earlyWarningAlarmLog/index.vue'
import WarningAlarmLog from './components/WarningAlarmLog/index.vue'
import WarningAlarmDispatch from './components/WarningAlarmDispatch/index.vue'
import hazardAssessment from './components/hazardAssessment/index.vue'
import foodSample from './components/foodSample/index.vue'
import assessList from './components/assessList/index.vue'
import appointList from './components/appointList/index.vue'


import { useCommonStore } from '@/stores/common'
let { setMoreSearch, setGloablParams } = useCommonStore()
type Props = {
	nowRowData?: any
}
const props = withDefaults(defineProps<Props>(), {
	nowRowData: {},
})

setMoreSearch({
	params: {
		creditCode: props.nowRowData.creditCode,
	},
})

let creditCode = props.nowRowData.creditCode || ''
const crud = ref()
const tabs = [
	{ label: '视频监控设备管理', name: '1', component: safetyRegulatoryInfo, creditCode },
	{ label: '智能设备管理', name: '2', component: intelligenceEquipment, creditCode },
	{ label: '设备维护记录', name: '3', component: maintenanceLog, creditCode },
	{ label: '日常防火巡查记录', name: '4', component: fireInspecteLog, creditCode },
	{ label: '月度防火巡查记录', name: '5', component: monthlyFireInspecte, creditCode },
	{ label: '消防维护记录', name: '6', component: fireMaintenance, creditCode },
	{ label: '消防演练记录', name: '7', component: fireDrill, creditCode },
	{ label: '消防安全教育培训记录', name: '8', component: safetyEduTrain, creditCode },
	{ label: '消防设施全面检测记录', name: '9', component: facilityTest, creditCode },
	{ label: '报警记录', name: '10', component: WarningAlarmLog, creditCode },
	{ label: '预警记录', name: '11', component: earlyWarningAlarmLog, creditCode },
	{ label: '报警调度记录', name: '12', component: WarningAlarmDispatch, creditCode },
	{ label: '隐患评估记录', name: '13', component: hazardAssessment, creditCode },
	{ label: '食品留样记录', name: '14', component: foodSample, creditCode },
	{ label: '出入院扫码登记记录', name: '15', component: assessList, creditCode },
	{ label: '家属预约探视登记记录', name: '16', component: appointList, creditCode },
	{ label: '家属预约老人出院记录', name: '17', component: appointOutList, creditCode },
]

let activeName = ref(tabs[0].name)
setGloablParams({
	authProvince: props.nowRowData.authProvince,
	authArea: props.nowRowData.authArea,
	authCity: props.nowRowData.authCity,
	authStreet: props.nowRowData.authStreet,
	authOrganizationId: props.nowRowData.authOrganizationId,
	authCommunity: props.nowRowData.authCommunity,
	organizationId: props.nowRowData.creditCode,
})
const onTabClick = (tab) => {
	activeName = tab.props.name
	setMoreSearch({
		params: {
			creditCode: props.nowRowData.creditCode,
		},
	})
	setGloablParams({
		authProvince: props.nowRowData.authProvince,
		authArea: props.nowRowData.authArea,
		authCity: props.nowRowData.authCity,
		authStreet: props.nowRowData.authStreet,
		authCommunity: props.nowRowData.authCommunity,
		organizationId: props.nowRowData.creditCode,
	})
	nextTick(() => {
		crud.value?.refreshChange({ dataType: tab.props.name })
	})
}
onUnmounted(() => {
	setMoreSearch({})
	setGloablParams({})
})
</script>

<style scoped></style>
